package com.czk.factory.support;

import com.czk.factory.config.BeanDefinition;
import com.czk.exception.BeansException;

/**
 * @Author:ChenZhangKun
 * @Date: 2023/2/19 10:23
 */
public abstract class AbstractAutowireCapableBeanFactory extends AbstractBeanFactory {
    @Override
    protected Object createBean(String name, BeanDefinition beanDefinition) throws BeansException {
        Object bean=null;
        try {
            bean=beanDefinition.getBeanClass().newInstance();
        }catch (InstantiationException | IllegalAccessException e){
            throw new BeansException(" Instantiation of bean failed",e);
        }
        // 注册到单例池
        registerSingleton(name,bean);
        return bean;
    }
}
